home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / c / SUPRALib.lha / SUPRALib / Developer / Source.ORG / _ftype.c next >
C/C++ Source or Header  |  1999-05-17  |  1KB  |  45 lines

  1. /*************************************************************
  2. *
  3. *    ---------------
  4. *   * Supra library *
  5. *    ---------------
  6. *
  7. *   -- File type --
  8. *   Demonstration of FileType()
  9. *
  10. *   Usage: ftype file
  11. *   file = file to be examined
  12. *   This function will return code 10 if provided file is
  13. *   a directory, code 5 if file does not exist, or 0 if
  14. *   it's a plain file.
  15. *
  16. *
  17. *   ©1995 by Jure Vrhovnik -- all rights reserved
  18. *   jurev@gea.fer.uni-lj.si
  19. *
  20. *************************************************************/
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <libraries/supra.h>
  25.  
  26. main(int argc, char *argv[])
  27. {
  28. LONG type;
  29.  
  30.     if (argc == 0) {
  31.         printf("Please run this program from CLI\n");
  32.     } else {
  33.         type = FileType(argv[1]);
  34.         if (type < 0) {
  35.             printf(" %s is a file\n", argv[1]);
  36.         } else if (type > 0) {
  37.             printf(" %s is a directory\n", argv[1]);
  38.             exit(10);
  39.         } else {
  40.             printf(" %s does not exist\n", argv[1]);
  41.             exit(5);
  42.         }
  43.     }
  44. }
  45.